method for completing the square